Skip to content

[3주차] 최유찬/[feat] 게시글 도메인 API 구현#101

Open
ruchan04 wants to merge 2 commits intoLeets-Official:최유찬/mainfrom
ruchan04:최유찬/3주차

Hidden character warning

The head ref may contain hidden characters: "\ucd5c\uc720\ucc2c/3\uc8fc\ucc28"
Open

[3주차] 최유찬/[feat] 게시글 도메인 API 구현#101
ruchan04 wants to merge 2 commits intoLeets-Official:최유찬/mainfrom
ruchan04:최유찬/3주차

Conversation

@ruchan04
Copy link
Copy Markdown

@ruchan04 ruchan04 commented Apr 7, 2026

1. 과제 요구사항 중 구현한 내용

  • 게시글 생성, 수정, 삭제
  • 게시글 조회, 존재하지 않는 게시글에 관한 안내
  • 잘못된 입력값으로 요청 받았을 때 해당 내용 안내
  • 요청에 대한 처리를 성공한 경우 / 실패한 경우에 대한 결과 메시지

2. 핵심 변경 사항

  1. 데이터 구조 확장 (Schema Expansion)
    단순 텍스트(content) 대신 리스트 형태의 blocks 구조를 도입하여 다양한 데이터를 담을 그릇을 만들었습니다.

  2. 응답 데이터 정밀화 (Data Curation)
    닉네임(yuchan)과 생성 시간(createdAt)을 추가하여 데이터의 식별성과 분석 가치를 높였습니다.

  3. 품질 관리 체계화 (Quality Control)
    4002(입력 오류), 4040(데이터 없음) 등 전용 에러 코드를 설계해 부적합한 데이터 유입을 차단했습니다.

3. 실행 및 검증 결과

  • 실행 결과:
    게시물 등록 성공
리츠 3주차

게시물 등록 오류
리츠 3주차1

게시물 조회
리츠 3주차2

4. 완료 사항

  1. 게시글 생성, 수정, 삭제, 조회
  2. 잘못된 입력 검증
  3. 요청 성공한 경우 / 실패한 경우 안내 메시지 지정

5. 추가 사항

  • 관련 이슈: closed #97

제출 체크리스트

  • PR 제목이 규칙에 맞다
  • base가 {이름}/main 브랜치다
  • compare가 {이름}/{숫자}주차 브랜치다
  • 프로젝트가 정상 실행된다
  • 본인을 Assignee로 지정했다
  • 파트 담당 Reviewer를 지정했다
  • 리뷰 피드백을 반영한 뒤 머지/PR close를 진행한다

Reviewer 참고

@ruchan04 ruchan04 self-assigned this Apr 7, 2026
@ruchan04 ruchan04 requested a review from a team April 7, 2026 06:02
@yeonjuncho
Copy link
Copy Markdown

고생하셨습니다.
다만 브런치 충돌이 일어난 것 같습니다. 수정 부탁드립니다.

Copy link
Copy Markdown

@LGH0507 LGH0507 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onSuccess와 onFailure를 따로 분리해서 제네릭 구조로 BaseResponse로 관리하신 점과 전체적으로 게시글 CRUD 작성을 깔끔하게 잘 하신 것 같습니다! 고생 많으셨습니다!


@Getter
@AllArgsConstructor
public class BaseResponse<T> {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

공통 응답을 제네릭을 활용해 데이터 타입을 유연하게 관리할 수 있도록 설계하고 onSuccess와 onFailure와 같은 정적 팩토리 메서드를 작성해 가독성도 높인 점 잘하셨고 고생하셨습니다! 👍

// [API 1] 목록 조회
@GetMapping
public BaseResponse<List<PostResponseDto>> getPosts() {
return BaseResponse.onSuccess("2000", "게시글 목록 조회 성공", postService.findAll());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추후에는 코드 확장성과 유지보수성 측면에서 좀 더 유리할 수 있도록 ErrorCode나 SuccessCode를 만들어 에러코드와 메시지를 한 번에 관리한다면 더 좋을 것 같습니다! 💊 아니면 혹시 저렇게("2000","게시글 목록 조회 성공") 으로 하드 코딩하신 이유가 따로 있으신 걸까요❓

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

지적 감사합니다 현재 프로젝트 초기 단계라 빠르게 API 구조를 잡느라 미처 공통 코드로 분리하지 못했습니다.

// 2. 상세 조회 로직
public PostResponseDto getPostDetail(Long postId) {
Post post = postRepository.findById(postId)
.orElseThrow(() -> new NoSuchElementException("해당 게시글을 찾을 수 없습니다."));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IllegalException 또는 GeneralException 대신 NoSuchElementException을 사용하신 의도가 따로 있으신건가요❓ 따로 사용해 본 적이 없어서 궁금해서 질문 드립니다!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IllegalArgumentException은 인자 값 자체가 잘못되었을 때(예: ID가 음수일 때) 주로 사용된다고 생각했습니다. 반면, 인자는 정상적이지만 DB에 해당 데이터가 존재하지 않는 상황을 좀 더 명확하게 표현하고 싶어서 '요소가 없음'을 뜻하는 NoSuchElementException을 선택해 보았습니다

Comment on lines +32 to +36
// [API 3] 작성
@PostMapping
public BaseResponse<PostResponseDto> createPost(@Valid @RequestBody PostRequestDto requestDto) {
return BaseResponse.onSuccess("2010", "게시글 생성 성공", postService.save(requestDto));
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

팀 과제 내용 반영해서 응답 메시지 잘 구성하신 것 같습니다. 고생 많으셨습니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants